// author by welong
// zuowl@qq.com
// 2014-09-05  19:05
// PAT basic 1019

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define BIT 4
//#define DEBUG
//#define INPUT_WAY_1	//get all point, 20
#define INPUT_WAY_2		//get 19 point

void sort(char *str)
{
	int i, j;
	char temp;
	
	for(i = 0; i < BIT-1; i++)
	{
		for(j = 0; j < BIT-1-i; j++)
		{
			if(str[j] < str[j+1])
			{
				temp = str[j];
				str[j] = str[j+1];
				str[j+1] = temp;
			}
		}
	}
}

void str_minus(char *str, char *min1, char *min2)
{
	int i = 0, mark = 0;
	
	for(i = 0; i < BIT; i++)
	{
		min1[i] = str[i];
		min2[i] = str[BIT-1 - i];
	}
	min1[i] = 0;
	min2[i] = 0;
	
	for(i = BIT-1; i >= 0; i--)
	{
		if(min1[i] - mark >= min2[i])
		{
			str[i] = min1[i]-mark - min2[i] + '0';
			mark = 0;
		}
		else
		{
			str[i] = min1[i]-mark - min2[i] + 10 +'0';
			mark = 1;
		}
	}
}

int judge(const char *str)
{
	int  i;
	char temp[BIT+1] = "6174";

	for(i = 0; i < BIT; i++)
	{
		if(str[i] != temp[i])
			return 0;
	}
	return 1;
}

int main(int argc, char **argv)
{
	int i, temp, input, count = 0;
	char num[BIT+1] ,m1[BIT+1], m2[BIT+1];

#ifdef DEBUG
while(1){
#endif

#ifdef INPUT_WAY_1
	scanf("%d", &input);				//input cna be (0 - 1000), maybe not 4 bit,cause test site 2,3,4 error
	
	for(i=0, temp=input; temp != 0; i++)
	{
		num[i] = temp%10 + '0';
		temp /= 10;
		count++;
	}
#endif
#ifdef INPUT_WAY_2
	scanf("%s", num);		//this mathod will cause test site 5 error
	count = strlen(num);
#endif

	for(; count < BIT; count++)
		num[count] = '0';
	num[count] = 0;

#ifdef DEBUG
	printf("num:%s\n", num);
	getchar();
	getchar();
#endif

	if(num[0] == num[1] && num[2] == num[3] && num[0] == num[2])
	{
		printf("%s - %s = 0000\n", num, num);
		return 0;
	}

	while(!judge(num))
	{
		sort(num);
		str_minus(num, m1, m2);
		printf("%s - %s = %s\n", m1, m2, num);
	}

#ifdef DEBUG
}
#endif
	return 0;
}
